package com.dxy.df.core.model;

import com.dxy.df.constants.ConstNumbers;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModel;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
 * <p>class_name: BasicQuery</p>
 * <p>package: com.dxy.df.core.model</p>
 * <p>@author: wangsheng@dxy.cn</p>
 * <p>@date: 2019-07-25 </p>
 **/
@NoArgsConstructor
@ApiModel
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class BasicQuery extends AbstractQuery {
    private static final long serialVersionUID = 1L;

    private Integer id;

    @NotNull(message = "page 不能为空")
    private Integer page = ConstNumbers.DEFAULT_PAGE;

    @NotNull(message = "limit 不能为空")
    private Integer limit = ConstNumbers.DEFAULT_LIMIT;

    @JsonIgnore
    private String sidx;

    @JsonIgnore
    private String order;

    @JsonIgnore
    private Integer offset;

    public Integer getOffset() {
        if (null == page || null == limit) {
            return null;
        }
        return (page - 1) * limit;
    }





    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public String getSidx() {
        return sidx;
    }

    public void setSidx(String sidx) {
        this.sidx = sidx;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}
